﻿// HSS.Data.Extensions.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       Extensions.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/05/2010
// ----------------------------------------------------------------------------
namespace HSS.Data
{
	/// <summary>
	/// HSS.Data Extensions
	/// </summary>
	public static class Extensions
	{
		#region IDataContainer
		/// <summary>
		/// Serializes an Object to Xml
		/// </summary>
		/// <param name="value">The Root Object</param>
		/// <returns>The Xml version of the instance</returns>
		public static string ToXml(this IDataContainer value)
		{
			return ObjectSerialization.ToXml(value);
		}
		/// <summary>
		/// A method for serializing an Instance of an object to an Xml File.
		/// </summary>
		/// <param name="value">The object to serialize to Xml</param>
		/// <param name="fileName">The file name and path where to write the object</param>
		public static void ToXmlFile(this IDataContainer value, string fileName)
		{
			ObjectSerialization.ToXmlFile(value, fileName);
		}
		/// <summary>
		/// Serializes an Object to a MemoryStream
		/// </summary>
		/// <param name="value">The Root Object</param>
		/// <returns>The Binary version of the instance in a MemoryStream</returns>
		public static System.IO.MemoryStream ToMemoryStream(this IDataContainer value)
		{
			return ObjectSerialization.ToMemoryStream(value);
		}
		/// <summary>
		/// Serializes an Object to an Array of Bytes
		/// </summary>
		/// <param name="value">The Root Object</param>
		/// <returns>The Binary version of the instance in an Array of Bytes</returns>
		public static byte[] ToByteArray(this IDataContainer value)
		{
			return ObjectSerialization.ToByteArray(value);
		}
		/// <summary>
		/// A method for serializing an Instance of an object to a File.
		/// </summary>
		/// <param name="value">The object to serialize to BinaryData</param>
		/// <param name="fileName">The file name and path where to write the object</param>
		public static void ToFile(this IDataContainer value, string fileName)
		{
			ObjectSerialization.ToFile(value, fileName);
		}
		#endregion
	}
}